package com.lvy.hczn.front.business.util.Mqtt;/*
package com.lvy.hczn.front.util.Mqtt;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import lombok.Data;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

@Data
public class ServerMqtt {

    private static String host = "tcp://47.99.107.115:";

    private static String topic = "test";

    private static String clientId = "server1";

    private MqttMessage message;

    private static MqttTopic connect(MqttClient client) throws MqttException {
        MqttConnectOptions options = new MqttConnectOptions();
        options.setCleanSession(false);
//        options.setUserName(userName);
//        options.setPassword(passWord.toCharArray());
        // 设置超时时间
        options.setConnectionTimeout(10);
        // 设置会话心跳时间
        options.setKeepAliveInterval(20);
        client.setCallback(new PushCallback());
        client.connect(options);
        return client.getTopic(topic);
    }

    */
/**
     * @param topic
     * @param message
     * @throws MqttPersistenceException
     * @throws MqttException
     *//*

    public void publish(MqttTopic topic, MqttMessage message) throws MqttPersistenceException,
            MqttException {
        MqttDeliveryToken token = topic.publish(message);
        token.waitForCompletion();
        System.out.println("message is published completely! " + token.isComplete());
    }

    */
/**
     * 启动入口
     *
     * @param args
     * @throws MqttException
     *//*

    public static void main(String[] args) throws MqttException {
        ServerMqtt server = new ServerMqtt();
        MqttClient client = new MqttClient(host, clientId);
        MqttTopic topic11 = connect(client);
        server.message = new MqttMessage();
        server.message.setQos(2);
        server.message.setRetained(true);
        server.message.setPayload("hello,topic11".getBytes());
        server.publish(topic11, server.message);
        System.out.println(server.message.isRetained() + "------ratained状态");
    }
}
*/
